<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
    <button type="button">按钮</button>
    <script type="text/javascript">
        var btn = document.querySelector("button");
        console.log(btn);
        
        btn.__proto__.addEvent = function(eventName,fn){
            if(this.event==undefined){
                this.event = {};
            };
            if(this.event[eventName]==undefined){
                this.event[eventName] = [];
                this.event[eventName].push(fn);
                this.addEventListener(eventName,function(event){
                    this.emit(eventName,event);//触发所有事件执行
                })
            }
        }

        btn.__proto__.emit = function(eventName,eventMsg){
            var fnlist = this.event[eventName];
            fnlist.forEach(function(item,i){
                item(eventMsg);
            })
        }

        btn.addEvent('click',function(event){
            console.log(event);
            document.body.style.background = "skyblue";
        });

     </script>
</body>

</html>